/***************************
* 1.框架初始化
****************************/

var myApp = new Framework7({
    modalTitle: document.title,
	pushState: false,
	precompileTemplates: true,
    animateNavBackIcon: true,
    cacheDuration: 1000*60*1,   // 缓存1分钟
	onAjaxStart: function (xhr) {
	    myApp.showIndicator();
	},
	onAjaxComplete: function (xhr) {
	    myApp.hideIndicator();
	},
    init: true,
});

// Expose Internal DOM library
var $$ = Dom7;

//初始化视图
var mainView = myApp.addView('.view-main', {
    //启用动态导航栏
    dynamicNavbar: false
});
// Show/hide preloader for remote ajax loaded pages
// Probably should be removed on a production/local app
$$(document).on('ajaxStart', function (e) {
    //myApp.showIndicator();
});
$$(document).on('ajaxComplete', function (e) {
    //myApp.hideIndicator();
});
$$(".open-panel").on("click",function(){
	//myApp.showPanel();
});
$$(".panel-close").on("click",function(){
	 myApp.closePanel();
});
// 跳转
$$(document).on("click","a",function(){
    var action = $$(this).attr("data-action");
    if(action == "home"){
        window.location.href = _home;
    }
    else if(action == "back"){
        if (mainView.activePage.fromPage != undefined) {
            mainView.router.back();
        }
        else {
            var href = $$(this).attr("data-href");
            if (href && href != "") {
                window.location.href = href;
            }
            else{
                window.history.back(-1);
            }
        }
    }
    else if(action == "history"){
        history.back(-1);
    }
    else if(action == "fw7"){
        var href = $$(this).attr("data-href");
        if (href && href != "") {
            mainView.router.loadPage({ url: href , reload: false });
        }
    }
    else{
        var href = $$(this).attr("data-href");
        if (href && href != "") {
            window.location.href = href;
        }
    }
    return false;
});

// 登录成功回调
var loginCallback;